<?php
/**
 *
 *
 * @version Sofortüberweisung 2.0  07.07.2008
 * @author Henri Schmidhuber  info@in-solution.de
 * @copyright 2006 - 2008 Henri Schmidhuber
 * @link http://www.in-solution.de
 * @link http://www.xt-commerce.com
 * @link http://www.sofort-ueberweisung.de
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 *
 ***********************************************************************************
 * this file contains code based on:
 * (c) 2000 - 2001 The Exchange Project
 * (c) 2001 - 2003 osCommerce, Open Source E-Commerce Solutions
 * (c) 2003	 nextcommerce (account_history_info.php,v 1.17 2003/08/17); www.nextcommerce.org
 * (c) 2003 - 2006 XT-Commerce
 * Released under the GNU General Public License
 ***********************************************************************************
 *
 */

  chdir('../../../../');
  require('includes/application_top.php');

  function create_random_value($length, $type = 'mixed') {
    if ( ($type != 'mixed') && ($type != 'chars') && ($type != 'digits')) return false;

    $rand_value = '';
    while (strlen($rand_value) < $length) {
      if ($type == 'digits') {
        $char = rand(0,9);
      } else {
        $char = chr(rand(0,255));
      }
      if ($type == 'mixed') {
        if (preg_match("/[a-z0-9]/i", $char)) $rand_value .= $char;
      } elseif ($type == 'chars') {
        if (preg_match("/[a-z]/i", $char)) $rand_value .= $char;
      } elseif ($type == 'digits') {
        if (preg_match("/[0-9]/i", $char)) $rand_value .= $char;
      }
    }

    return $rand_value;
  }

  // Module already installed
  if (defined('MODULE_PAYMENT_SOFORTUEBERWEISUNG_DIRECT_STATUS') && (MODULE_PAYMENT_SOFORTUEBERWEISUNG_DIRECT_STATUS == 'True')) {
    die('Modul bereits installiert<br><a href="' . href_link(FILENAME_MODULES, 'set=payment&module=sofortueberweisung_direct', 'SSL') . '">zurРЎРЉck zum ShopAdmin</a>');
  }

  $parameter = array();
  $parameter['install'] = 'sofortueberweisung_direct';
  $parameter['action'] = 'install';
  $parameter['project_passwort'] = create_random_value(12);
  $parameter['currency'] = 'EUR';

  $get_parameter = '';
  $x = 0;
  while(list($key,$value) = each($parameter)) {
    if (empty($value)) continue;
    if ($x > 0) $get_parameter .= "&";
    $get_parameter .= $key . "=" . urlencode($value);
    $x++;
  }

  $backlink = href_link('ext/modules/payment/sofortueberweisung/modules.php', $get_parameter);
  $vpartner = '';
  $header_redir_url = 'http://-USER_VARIABLE_2-';
  if (ENABLE_SSL_CATALOG == 'true' && strpos(HTTPS_CATALOG_SERVER, 'tps://') === 2) {
    $header_redir_url = 'https://-USER_VARIABLE_2-'; //
  }

  $html_abortlink =  'http://-USER_VARIABLE_3-';
  if (ENABLE_SSL_CATALOG == 'true' && strpos(HTTPS_CATALOG_SERVER, 'tps://') === 2) {
    $html_abortlink = 'https://-USER_VARIABLE_3-'; //
  }

  $alert_http_url = 'http://-USER_VARIABLE_4-';
  if (ENABLE_SSL_CATALOG == 'true' && strpos(HTTPS_CATALOG_SERVER, 'tps://') === 2) {
    $alert_http_url = 'https://-USER_VARIABLE_4-'; //
  }

  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'install')) {
    $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
    $class = 'sofortueberweisung_direct';

    if (file_exists(DIR_FS_CATALOG_MODULES . 'payment/sofortueberweisung_direct' . $file_extension)) {
      include(DIR_FS_CATALOG_MODULES . 'payment/sofortueberweisung_direct' . $file_extension);
      $module = new $class;
      $module->install();
    }

    redirect(href_link(FILENAME_MODULES, 'set=payment&module=sofortueberweisung_direct', 'SSL'));
  }
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://www.sofortueberweisung.de/cms/modul/style.css">
<style>
input {Font-family:tahoma,arial,verdana; font-size:11px; color:#666666; background-color:#FFFFFF; border:1px solid #808080;}
select {Font-family:tahoma,arial,verdana; font-size:11px; color:#666666; background-color:#FFFFFF; border:1px solid #808080;}
</style>
</head>
<body background="https://www.sofortueberweisung.de/cms/design/kachel.gif" leftmargin="0" topmargin="5" marginwidth="0" marginheight="0" onLoad="javascript:init()">
<form method="post" action="https://www.sofort-ueberweisung.de/payment/createNew/" id="form">

<table align="center" width="970" height="205" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <img src="https://www.sofortueberweisung.de/payment/img/head_image.gif" />
    </td>
  </tr>
  <tr>
    <td>
	  <img src="https://www.sofortueberweisung.de/cms/p.gif" width=5 height=5 alt="" border=0 vspace=0 hspace=0>
	</td>
  </tr>
  <tr>
    <td>
      <table align="center" width="970" border="0" cellpadding="0" cellspacing="0">
	    <tr>
		  <td><img src="https://www.sofortueberweisung.de/cms/design/content_01.gif" width="190" height="10" alt="" border=0 vspace=0 hspace=0></td>
		  <td><img src="https://www.sofortueberweisung.de/cms/design/content_02.gif" width="212" height="10" alt="" border=0 vspace=0 hspace=0></td>
		  <td align="right"><img src="https://www.sofortueberweisung.de/cms/design/content_03.gif" width="568" height="10" alt="" border=0 vspace=0 hspace=0></td>
	    </tr>
	  </table>
	</td>
  </tr>
  <tr>
    <td bgcolor="white">
    <table width="100%" border="0">
    	  <tr>
    	    <td width="50%">
    	    <table border="0" cellspacing="0" id="table6" style="padding-left: 20px;">
            <tr><td>Projekt Name </td><td><input type="text" name="project_name" value="<?php echo STORE_NAME; ?>"></td><td>*</td></tr>
            <tr><td>Homepage</td><td><input type="text" name="project_homepage" value="<?php echo catalog_href_link() ;?>"></td><td>*</td></tr>
            <tr><td>Email</td><td><input type="text" name="projectsnotification_email_email" value="<?php echo STORE_OWNER_EMAIL_ADDRESS; ?>"></td><td>&nbsp;</td></tr>
          </table>
          <br />
          <br />
          <table border="0" cellpadding="2" cellspacing="0" style="padding-left: 20px;">
        	  <tr>
	            <td colspan="2">
	              <input type="submit" name="Absenden" value="Absenden"><br><b>Nach der Registrierung des Projekts bei SofortРЎРЉberweisung, unbedingt dem Link zurРЎРЉck zum Shop folgen!</b>
		        </td>
	          </tr>
	        </table></td>
	      </tr>
	    </table>
    </td>
  </tr>
  <tr>
    <td>
	  <table width="970" border="0" cellspacing="0" cellpadding="0">
	    <tr>
		  <td width="190" valign="top"><img src="https://www.sofortueberweisung.de/cms/design/content_11.gif" width=190 height=10 alt="" border=0 vspace=0 hspace=0></td>
		  <td bgcolor="white"><img src="https://www.sofortueberweisung.de/cms/p.gif" width=5 height=10 alt="" border=0 vspace=0 hspace=0></td>
		  <td align="right" width="568"><img src="https://www.sofortueberweisung.de/cms/design/content_13.gif" width=568 height=10 alt="" border=0 vspace=0 hspace=0></td>
		</tr>
	  </table>
	</td>
  </tr>
</table>
<table border="1" id="table7" style="display:none">
  <tr><td>Email Benachrichtigung bei Zahlungseingang aktivieren</td><td><input type="text" name="projectsnotification_email_activated" value="1"></td><td>&nbsp;</td></tr>
</table>

<input type="hidden" name="backlink" value="<?php echo $backlink; ?>">
<input type="hidden" name="user_partner_id" value="<?php echo $vpartner; ?>">
<input type="hidden" name="projectssetting_interface_cancel_link" value="<?php echo $html_abortlink; ?>">
<input type="hidden" name="projectssetting_interface_success_link_redirect" value="1">
<input type="hidden" name="projectssetting_interface_success_link" value="<?php echo $header_redir_url; ?>">
<input type="hidden" name="projectssetting_currency_id" value="EUR">
<input type="hidden" name="projectssetting_locked_amount" value="1">
<input type="hidden" name="projectssetting_locked_reason_1" value="1">
<input type="hidden" name="projectssetting_locked_reason_2" value="1">
<input type="hidden" name="projectssetting_interface_input_hash_check_enabled" value="1">
<input type="hidden" name="projectssetting_project_password" value="<?php echo $parameter['project_passwort']; ?>">
<input type="hidden" name="project_shop_system_id" value="4">
<input type="hidden" name="user_shop_system_id" value="4">

<input type="hidden" name="projectsnotification_http_activated" value="1">
<input type="hidden" name="projectsnotification_http_url" value="<?php echo $alert_http_url; ?>">
<input type="hidden" name="projectsnotification_http_method" value="1">
<input type="hidden" name="debug" value="0">
</form>

</body>
</html>